import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class ClientDemo {

	public static void main(String[] args) throws Exception {
		URL url;
		url = new URL(
				"http://192.168.0.105:8080/mobileapp/auth?action=login&repository=DES&userId=zhengli&password=zhengli");
		HttpURLConnection conn = (HttpURLConnection) url.openConnection();
		if (conn.getResponseCode() != 200)
			System.out.println("fail");
		InputStream is = conn.getInputStream();
		byte[] temp = new byte[1024];
		int n = 0;
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		while ((n = is.read(temp)) != -1) {
			bos.write(temp, 0, n);
		}
		byte[] msgBody = bos.toByteArray();
		bos.close();
		is.close();
		String returnXml = new String(msgBody, "UTF-8").trim();
		conn.disconnect();
		System.out.println(returnXml);
	}

}
